import React from 'react'
import { createBehavior, createResource } from '@designable/core'
import { DnFC } from '@designable/react'
import { AllSchemas } from '../../schemas'
import { AllLocales } from '../../locales'
import { Dialog as CustomDialog } from '@/customComponents'
import { createVoidFieldSchema } from '../Field'

export const Dialog: DnFC<React.ComponentProps<any>> = CustomDialog

Dialog.Behavior = createBehavior({
  name: 'Dialog',
  extends: ['Field'],
  selector: (node) => node.props['x-component'] === 'Dialog',
  designerProps: {
    droppable: true,
    propsSchema: AllSchemas.Dialog,
  },
  designerLocales: AllLocales.Dialog,
})

Dialog.Resource = createResource({
  icon: 'Dialog',
  elements: [
    {
      componentName: 'Field',
      props: {
        type: 'void',
        'x-component': 'Dialog',
        'x-component-props': {
          dialogName: 'modal',
        },
      },
    },
  ],
})
